
Ext.define('DCApp.view.attach.List', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.attachlist',
    
    requires: [
        'DCApp.view.attach.ListController',
        'DCApp.view.attach.ListModel',
        'DCApp.view.GridFilters'
    ],

    // Connects to our View Controller (Ticket.view.ticket.SearchController) and View Model
    // (Ticket.view.ticket.SearchModel).
    controller: 'attachlist',
    plugins: ['gfilters'],
    viewModel: {
        type: 'attachlist'
    },
    header:false,
    selType: 'checkboxmodel',
    bind: {
        store: '{objs}'
    },
    
    tbar: ['->',{
  	  xtype:'filefield',
	  listeners:{
	        afterrender:function(cmp){
	            cmp.fileInputEl.set({
	                multiple:'multiple'
	            });
	        }
	    }
  },{
      text: '上传',
      handler: 'onUpload'
  },{
      text: '删除',
      handler: 'onRemove'
  }],
    
	bubbleEvents:['viewattach'],
	
	listeners: {
        itemdblclick: 'onDblClick'
    },
    
    columns: [
            {
                text     : '编号',
                dataIndex: 'id',
                filter: 'number'
            },
            {
                text     : '题名',
                dataIndex: 'name',
                filter: {
                    type: 'string',
                    itemDefaults: {
                        emptyText: 'Search for...'
                    }
                }
            },{
                text     : '文件大小',
                dataIndex: 'filesize',
                filter: 'number'
            },{
                text     : '类型',
                dataIndex: 'suffix',
                filter: {
                    type: 'list',
                    options: [
                      ['jpg', 'jpg'],
                      ['doc', 'doc'],
                      ['xls', 'xls'],
                      ['zip', 'zip']
                  ]
                }
            },{
                text     : '路径',
                dataIndex: 'path',
                renderer:function(v,r,rec, rowIndex, columnIndex, store){
                	return "<a target='_blank' href='"+v+"'>"+v+"</a>";
                }
            }
        ],
    initComponent: function(){
    	 this.callParent();
    }
 });
